﻿using PlayNote.Bll;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PlayNote.Model
{
    public class NoteTable
    {
        public int Id { get; set; }
        public string Msg { get; set; }=string.Empty;
        public DateTime CreateTime { get; set; }=DateTime.Now;
        public DateTime UpdateTime { get; set; }=DateTime.Now;
        public bool IsDeleted { get; set; }
    }
    public class NoteTableViewModel : PlayNugetPackage.WPF.ViewModelBase
    {
        ObservableCollection<NoteTable> noteTables = new ObservableCollection<NoteTable>();
        public NoteTableViewModel()
        {
            Refrsh();
        }
        public ObservableCollection<NoteTable> NoteTables
        {
            get {return noteTables;}
            set {noteTables = value; OnPropertyChanged(); }
        }

        public void Refrsh()
        {
            NoteTableBll.GetAll().ForEach(m => { if (noteTables.FirstOrDefault(n => n.Id == m.Id) == null) { noteTables.Add(m); } });
        }
    }
}
